package cn.fan.feign.clients.fallback;

import cn.fan.feign.clients.UserClient;
import cn.fan.feign.pojo.User;
import cn.fan.utils.R;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;

@Slf4j
public class UserClientFallbackFactory implements feign.hystrix.FallbackFactory<UserClient> {
    private static final long FAIL = -1L;
    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
//            @Override
//            public User sysUser() {
//                log.error("查询用户失败！",throwable);
//                return new User();
//            }
//            @Override
//            public long sysUserId(){
//                log.error("查询用户失败！",throwable);
//                return FAIL;
//            }

            @Override
            public R get(long id) {
                log.error("查询用户失败！",throwable);
                return R.error();
            }

            @Override
            public R list(Map<String,Object> map){
                log.error("查询用户失败！",throwable);
                return R.error();
            }
        };
    }
}
